package de.baumann.browser.fragments.duobao

import android.view.View
import de.baumann.browser.OdinGlideModule
import de.baumann.browser.R
import de.baumann.browser.activitys.duobao.AddressActivity
import de.baumann.browser.activitys.duobao.DuoBaoJiangPinActivity
import de.baumann.browser.activitys.duobao.OrderRecordActivity
import de.baumann.browser.base.BaseOdinFragment
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IBaseView
import de.baumann.browser.utils.UnicornUtil
import de.baumann.browser.utils.getUser
import de.baumann.browser.utils.getUserName
import de.baumann.browser.utils.web3j.BalanceTask
import kotlinx.android.synthetic.main.fragment_duo_bao_wo.*

class DuoBaoWoFragment : BaseOdinFragment<IBaseView, BasePresenter<IBaseView>>() {

    companion object {
        val instance: DuoBaoWoFragment by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            DuoBaoWoFragment()
        }
    }

    override fun getLayout(): Int {
        return R.layout.fragment_duo_bao_wo
    }

    override fun initView(view: View) {
        duobaoOrders.setOnClickListener {
            OrderRecordActivity.startOrderRecordActivity(mContext)
        }

        jiangPin.setOnClickListener {
            DuoBaoJiangPinActivity.startDuoBaoJiangPinActivity(mContext)
        }

        shouhuoAddress.setOnClickListener {
            AddressActivity.startAddressActivity(mContext)
        }

        lxkf.setOnClickListener {
            UnicornUtil.openServiceActivity(mContext,mContext.javaClass.name)
        }
    }

    override fun initData() {
        woUserName.text = getUserName()
        woPhone.text = getUser()?.phone
        woAddress.text  = getUser()?.eth_address
        OdinGlideModule.loadWithCropAndCircle(mContext, getUser()?.headUrl,woHead,R.drawable.icon_head)
        BalanceTask(odin,"ODIN").execute(getUser()?.eth_address)
    }

    override fun createPresenter(): BasePresenter<IBaseView>? {
        return null
    }

    override fun createView(): IBaseView? {
        return null
    }

}